namespace Digitalmes.Application.Sys.Posts.Queries;

/// <summary>
/// 职位分页查询命令。
/// </summary>
public record GetPosListWithPagedQuery (int PageNumber, int PageSize) : IPagedQuery, IRequest<IResult<PagedList<SysPosDto>>>;

public sealed class GetPosListWithPagedQueryHandler(IRepository<SysPos> repo) : IRequestHandler<GetPosListWithPagedQuery, IResult<PagedList<SysPosDto>>>
{
    public async Task<IResult<PagedList<SysPosDto>>> Handle(GetPosListWithPagedQuery request, CancellationToken cancellationToken)
    {
        var items = await repo.GetPagedListAsync(request.PageNumber, request.PageSize, cancellationToken);
        return Result.From(items.Adapt<PagedList<SysPosDto>>());
    }
}
